
    <title>应付派送费</title>
    <style type="text/css">
        .layui-form-select .layui-input {
            padding-right: 0px;
            cursor: pointer;
        }
    </style>
   <div class="layui-fluid" style="padding: 15px">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header" style="height: 130px">
                    <form class="layui-form layui-form-pane" action="#" lay-filter="example">
                        <div class="layui-col-md3">
                            <div class="layui-form-item">
                                <label class="layui-form-label"> 派送单号： </label>
                                <div class="layui-inline">
                                    <input name="delivery_id" class="layui-input" autocomplete="off">
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md3">
                            <div class="layui-form-item">
                                <label class="layui-form-label">托运单号：</label>
                                <div class="layui-inline">
                                    <input name="waybill_id" class="layui-input" id="forwardingunit" autocomplete="off">
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md3">
                            <div class="layui-form-item">
                                <label class="layui-form-label">派送日期：</label>
                                <div class="layui-inline">
                                    <input type="date"  name="deliveryDate"  placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md3">
                            <div class="layui-form-item">
                                <label class="layui-form-label">所在分站：</label>
                                <div class="layui-inline">
                                    <select id="substationUnit" name="sub_id">
                                        <option value="">请选择</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md3">
                            <div class="layui-form-item">
                                <label class="layui-form-label">派送司机：</label>
                                <div class="layui-inline">
                                    <input name="ownerName" class="layui-input"  autocomplete="off">
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md3">
                            <div class="layui-form-item">
                                <label class="layui-form-label">核销状态：</label>
                                <div class="layui-inline">
                                    <select name="verification">
                                        <option value="">请选择</option>
                                        <option value="false">false</option>
                                        <option value="ture">ture</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md3">
                            <div class="layui-form-item">
                                <button type="button"  class="layui-btn layui-btn-sm" lay-submit lay-filter="souSuo">搜索数据</button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="layui-card-body">
                    <table id="consigner" lay-filter="consignerTable"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="toolbarMenu">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="addMenutble">派送核销</button>
    </div>
</script>
<script>
    layui.use(['form','jquery','table'], function() {
        var form = layui.form;
        var $ = layui.jquery;
        var table = layui.table;

        form.render();
        //动态新增下拉框
        $.ajax({
            url: "../../getAllSubstation",
            type: "post",
            data: {},
            dataType: "json",
            success: function (data) {
                //动态添加下拉框
                for (var i = 0; i < data.length; i++) {
                    $("#substationUnit").append("<option value='" + data[i].subId + "'>" + data[i].subName + "</option>");
                }
                //刷新
                form.render('select')
            }
        })




        //菜单表格
        table.render({
            elem: '#consigner'
            ,height: 500
            ,id:'consignerTable'
            ,url: '../../DeliveryChargeControllerGetAllDeliveryCharge' //数据接口
            ,toolbar: '#toolbarMenu' //开启头部工具栏，并为其绑定左侧模板
            ,limit:8
            ,limits:[8,16,24,32]
            ,defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
                title: '提示'
                ,layEvent: 'LAYTABLE_menu'
                ,icon: 'layui-icon-tips'
            }]
            ,page: true //开启分页
            ,cols: [[ //表头
                {type: 'checkbox', fixed: 'left'}
                ,{field: 'delivery_id',width:180, title: '派送单号'}
                ,{field: 'deliveryDate',width:180,title: '派送日期'}
                ,{field: 'waybill_id', width:220,title: '运单号'}
                ,{field: 'sub_name',width:180, title: '分站名称'}
                ,{field: 'ownerName',width:220, title: '司机名称'}
                ,{field: 'licenseTag', width:180,title: '车牌'}
                ,{field: 'phone',width:120, title: '电话号码'}
                ,{field: 'cost', width:120,title: '派送成本'}
                ,{field: 'verification',width:120, title: '是否核销'}
                ,{field: 'finance',width:180, title: '财务订单号'}
                ,{field: 'announcements',width:120, title: '派送备注',}
            ]]
        })



        //角色头部工具栏头工具栏事件
        table.on('toolbar(consignerTable)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data;
            if (data.length==0){
                alert("请选择一行")
            } else if (data.length>1){
                alert("只能选中一行")
            }else {
                switch(obj.event) {
                    case 'addMenutble':
                        $.ajax({
                            url: "../../../DeliveryChargeControllerUpdateVerification",
                            type: "post",
                            data: {
                                id:data[0].finance
                            },
                            dataType: "text",
                            success: function (data) {
                                table.reload('consignerTable');
                            }
                        })
                        return false;
                        break;
                };
            }
        });



        //提交数据
        form.on('submit(souSuo)', function(data){
            //执行重载
            table.reload('consignerTable', {
                page: {
                    curr: 1 //重新从第 1 页开始
                }
                //根据条件查询
                ,where: data.field
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    })
</script>